package grafico;

import java.awt.Color;
import javax.swing.JPanel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.ImageIcon;
import javax.swing.JTextField;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.JPasswordField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;



public class Autenticarse extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private JTextField campoUsuario;
	private JPasswordField passwordField;

	/**
	 * Create the panel.
	 */
	public Autenticarse(final PantallaPrincipal frame) {
		setBackground(new Color(105, 105, 105));
		
		ImageIcon img=new ImageIcon(this.getClass().getResource("/imagenes/icono.jpg"));
		
		JLabel lblHotel = new JLabel("Hotel LaRibera");
		lblHotel.setForeground(Color.WHITE);
		lblHotel.setFont(new Font("Tahoma", Font.BOLD, 30));
		
		JLabel icono = new JLabel(img);
		
		JLabel lblAutenticarse = new JLabel("Autenticarse");
		lblAutenticarse.setFont(new Font("Tahoma", Font.PLAIN, 24));
		lblAutenticarse.setForeground(new Color(255, 102, 102));
		lblAutenticarse.setBackground(new Color(255, 102, 102));
		JLabel lblUsuario = new JLabel("Usuario:");
		lblUsuario.setFont(new Font("Tahoma", Font.BOLD, 14));
		lblUsuario.setForeground(Color.WHITE);
		
		campoUsuario = new JTextField();
		campoUsuario.setColumns(10);
		
		JButton btnCancelar = new JButton("Cancelar\r\n");
		btnCancelar.setForeground(new Color(0, 102, 153));
		btnCancelar.setBackground(Color.LIGHT_GRAY);
		btnCancelar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		
		JLabel lblContrasea = new JLabel("Contrase\u00F1a:");
		lblContrasea.setForeground(Color.WHITE);
		lblContrasea.setFont(new Font("Tahoma", Font.BOLD, 14));
		
		JButton btnIngresar = new JButton("Ingresar");
		btnIngresar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				ingresar(frame);
			}

			
		});
		
		passwordField = new JPasswordField();
		btnIngresar.setForeground(new Color(0, 102, 153));
		btnIngresar.setBackground(Color.LIGHT_GRAY);
		btnIngresar.setFont(new Font("Tahoma", Font.PLAIN, 16));
		btnCancelar.setFont(new Font("Tahoma", Font.PLAIN, 16));
		GroupLayout groupLayout = new GroupLayout(this);
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(75)
							.addComponent(lblHotel)
							.addGap(378)
							.addComponent(icono))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(7)
							.addComponent(lblAutenticarse, GroupLayout.PREFERRED_SIZE, 151, GroupLayout.PREFERRED_SIZE))
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(88)
							.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
								.addComponent(btnIngresar, GroupLayout.PREFERRED_SIZE, 97, GroupLayout.PREFERRED_SIZE)
								.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
									.addGroup(groupLayout.createSequentialGroup()
										.addComponent(lblUsuario)
										.addPreferredGap(ComponentPlacement.RELATED, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
										.addComponent(campoUsuario, GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE))
									.addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup()
										.addComponent(lblContrasea)
										.addGap(37)
										.addComponent(passwordField, GroupLayout.PREFERRED_SIZE, 196, GroupLayout.PREFERRED_SIZE))))
							.addPreferredGap(ComponentPlacement.UNRELATED)
							.addComponent(btnCancelar)))
					.addContainerGap(7, Short.MAX_VALUE))
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addGap(7)
					.addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
						.addGroup(groupLayout.createSequentialGroup()
							.addGap(52)
							.addComponent(lblHotel))
						.addComponent(icono, GroupLayout.PREFERRED_SIZE, 141, GroupLayout.PREFERRED_SIZE))
					.addGap(4)
					.addComponent(lblAutenticarse)
					.addGap(28)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(lblUsuario)
						.addComponent(campoUsuario, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(passwordField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
						.addComponent(lblContrasea))
					.addGap(18)
					.addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
						.addComponent(btnIngresar, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE)
						.addComponent(btnCancelar, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
					.addContainerGap(184, Short.MAX_VALUE))
		);
		setLayout(groupLayout);
		
		
	}
	
	private void ingresar(PantallaPrincipal frame) {
		this.setVisible(false);
		frame.setContentPane(new Menu(frame));
		
	}
}
